package com.chushouya.manager.dto.admin.log;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.general.framework.core.enums.BusinessStatus;
import com.general.framework.core.enums.ContextUserType;
import com.general.framework.core.lang.Dates;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

@ApiModel("操作日志")
@Data
public class OperateLogListDTO {

    @ApiModelProperty("日志ID")
    private Long id;

    @ApiModelProperty("服务类型")
    private String serviceType;

    @ApiModelProperty("模块")
    private String modelName;

    @ApiModelProperty("操作")
    private String operateName;

    @ApiModelProperty("请求URL")
    private String url;

    @ApiModelProperty("请求方式")
    private String method;

    @ApiModelProperty("业务类型")
    private String businessType;

    @ApiModelProperty("用户类型")
    private Integer contextUserType;

    @ApiModelProperty("用户类型")
    private String contextUserTypeName;

    @ApiModelProperty("操作人员")
    private String contextUser;

    @ApiModelProperty("主机地址")
    private String ip;

    @ApiModelProperty("操作状态（0失败,1成功）")
    private Integer status;

    @ApiModelProperty("操作状态（0失败,1成功）")
    private Integer statusDesc;

    @ApiModelProperty("操作时间")
    @JsonFormat(pattern = Dates.FMT_FULL_TIME)
    private Date time;

    @ApiModelProperty("请求参数")
    private String param;

    @ApiModelProperty("返回参数")
    private String result;

    @ApiModelProperty("错误消息")
    private String msg;

    public String getStatusDesc() {
        return BusinessStatus.getDesc(this.status);
    }

    public String getContextUserTypeName() {
        return ContextUserType.getDesc(this.contextUserType);
    }
}
